/**
 * PHOSIDE: PHosphorylation Site IDentification Engine.
 * Copyright 2009 Digital Biology Lab, University of Missouri.
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 3 of the License, or (at your option) any later
 * version. <p/> This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more
 * details.
 */

package phoside.io.xml;

import java.util.ArrayList;

import phoside.util.StaticFinalValues;

/**
 *
 * @author gjj
 */
public class PhosideResultFieldValueFormatter
        extends PhosphoProteinFieldValueFormatter {
    @Override
    public Object read(String fieldName, String value) {
        if (fieldName==null || value==null) {
            return null;
        }

        if (fieldName.compareTo(StaticFinalValues.PREDICTION)==0) {
            String[] strs = value.split(StaticFinalValues.SEPARATOR);
            ArrayList<Double> scores = new ArrayList(strs.length);
            for (String str : strs) {
                scores.add(Double.valueOf(str));
            }

            return scores;
        }

        return super.read(fieldName, value);
    }
}
